// https://leetcode-cn.com/problems/reverse-integer/

public int reverse(int x)
{
    long result = 0;
    int tmp = 0;
    while (x!=0)
    {
        result = result * 10 + x % 10;
        if (tmp != ((int)result / 10))
        {
            return 0;
        }
        tmp = (int)result;
        x /= 10;
    }
    return tmp;
}